//
//  RBCommonMacro.h
//  RMMaterialRed
//
//  Created by XBWH on 2024/3/12.
//

#ifndef RBCommonMacro_h
#define RBCommonMacro_h

#ifdef DEBUG
#define RB_DBG(...) NSLog(__VA_ARGS__)
#else
#define RB_DBG(...)
#endif

///尺寸
#define RBIsIPad ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad)
#define RBScaleWidth(__VA_ARGS__)  ((RBIsIPad == YES) ? 1.5 : [UIScreen mainScreen].bounds.size.width/375)*(__VA_ARGS__)
#define RBScaleHeight(__VA_ARGS__)  ([UIScreen mainScreen].bounds.size.height/667)*(__VA_ARGS__)
#define RBScreenWidth  [UIScreen mainScreen].bounds.size.width
#define RBScreenHeight  [UIScreen mainScreen].bounds.size.height
#define RBIsIphoneXAll (UIApplication.sharedApplication.keyWindow.safeAreaInsets.top > 20 ? YES :NO)

#define RBSTATUS_BAR_HEIGHT [[RBTool rb_getCurrentController] RBStatusBarH]
#define RBNAVIGATION_BAR_HEIGHT [[RBTool rb_getCurrentController] RBNavigationBarH]
#define RBTAB_BAR_HEIGHT [[RBTool rb_getCurrentController] RBTabBarH]
#define RBHOME_INDICATOR_HEIGHT ((RBIsIphoneXAll == YES) ? 34.f : 0.f)

///颜色
#define RBColor(r, g, b) [UIColor colorWithRed:(r)/255.0 green:(g)/255.0 blue:(b)/255.0 alpha:1.0]
#define RBColorRGBA(r, g, b, a) [UIColor colorWithRed:(r)/255.0 green:(g)/255.0 blue:(b)/255.0 alpha:(a)]
#define RBColorFromRGB(rgbValue) [UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 green:((float)((rgbValue & 0xFF00) >> 8))/255.0 blue:((float)(rgbValue & 0xFF))/255.0 alpha:1.0]
#define RBHexColor(f)   [UIColor rb_colorWithHexString:f]
#define RBHexColorAndalpha(f, a)   [UIColor rb_colorWithHexString:f alph:a]
///字体
#define GreaterThan_IOS9 ([[[UIDevice currentDevice] systemVersion] floatValue] >= 9.0)
#define RBCommonFont(__size__,__bold__) ((__bold__)?([UIFont boldSystemFontOfSize:__size__]):([UIFont systemFontOfSize:__size__]))
#define RBPingFangFont(n) GreaterThan_IOS9 ? [UIFont rb_RegularFontOfSize:n] : RBCommonFont(n,NO)
#define RBPingFangBlodFont(n) GreaterThan_IOS9 ? [UIFont rb_SemiboldFontOfSize:n] : RBCommonFont(n,YES)
#define RBPingFangMediumFont(n) GreaterThan_IOS9 ? [UIFont rb_MediumFontOfSize:n] : RBCommonFont(n,YES)
#define RBPingFangLightFont(n) GreaterThan_IOS9 ? [UIFont rb_LightFontOfSize:n] : RBCommonFont(n,YES)
#define RBPingFangHeavyFont(n) GreaterThan_IOS9 ? [UIFont rb_HeavyFontOfSize:n] : RBCommonFont(n,YES)

///按钮第二次点击事件触发的等待时间
#define Button_Seconds_Time(_seconds_) \
static BOOL shouldPrevent; \
if (shouldPrevent) return; \
shouldPrevent = YES; \
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)((_seconds_) * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ \
shouldPrevent = NO; \
});

///获取Window
#define RBWindow [UIApplication sharedApplication].keyWindow

#define RBObjectIsEmpty(object)  (object == nil||[object isKindOfClass:[NSNull class]]||([object respondsToSelector:@selector(length)] && [(NSData *)object length] == 0)|| ([object respondsToSelector:@selector(count)] && [(NSArray *)object count] == 0)?YES:NO)
#define RBStringIsEmpty(string) ([string isKindOfClass:[NSNull class]] || string == nil || [string length] < 1 ? YES : NO )
#define RBArrayIsEmpty(array) (array == nil || [array isKindOfClass:[NSNull class]] || array.count == 0? YES : NO)
#define RBDictionaryIsEmpty(dictionary) (dictionary == nil || [dictionary isKindOfClass:[NSNull class]] || dictionary.allKeys.count == 0? YES : NO)

//极光
#define JPUSH_APPKEY @"92d48e50e82532df4742a8a6"

#endif /* RBCommonMacro_h */
